/*
 * =====================================================================================
 *
 *       Filename:  helloworld.c
 *
 *    Description:  第一个linux module编写
 *
 *        Version:  1.0
 *        Created:  2018年08月28日 17时05分35秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  NYB (), niuyabeng@126.com
 *   Organization:  
 *
 * =====================================================================================
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/moduleparam.h>
#define BIZ_MAX 8
#define LEN_IFNAME 32
static char *biz[BIZ_MAX] = {0};
static char gap[LEN_IFNAME] = {0};
static int len_biz = 0;
module_param_array(biz, charp, &len_biz, S_IRUGO);
module_param_string(gap, gap, LEN_IFNAME, S_IRUGO);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("NYB");


static int helloworld_export_symbol(void)
{
    return 1;
}

static int helloworld_init(void)
{
    int i;
    printk(KERN_EMERG"%s: start\n", __func__);
    if(len_biz <= 0) {
        printk(KERN_EMERG"len_biz <= 0\n");
        return -1;
    }
    for(i = 0; i < len_biz; i++) {
        if(biz[i]) {
            printk(KERN_EMERG"biz[%d]: %s\n", i, biz[i]);
        }
    }
    printk(KERN_EMERG"gap: %s\n", gap);
    return 0; 
}

static void helloworld_exit(void)
{
    printk(KERN_EMERG"%s: start\n", __func__);
}
 
module_init(helloworld_init);
module_exit(helloworld_exit);

